<?php
/**
 * 控制器 
 * 负责将请求重定向到模型
 */
class Controller{
    private $action;
    private $file_path;

    /**
     * 初始化控制器，对$action赋值
     * @param $_GET $get
     */
    function __construct($get){
        $this->action = $get['action'];
    }
    private function dispatcher(){
        $this->file_path = 'model/';
        // 构造file_path 
        $this->file_path = $this->file_path.$this->action.'.php';
    }
    public function run()
    {
        $this->dispatcher();
        require($this->file_path);
    }
}

$controller = new Controller($_GET);
$controller->run();

?>